<div class="pageContent">
        <if condition="isset($regioninfo)">
            <form method="post" action="__URL__/update" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
        <else />
            <form method="post" action="__URL__/insert" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
        </if>

        <div class="pageFormContent" layoutH="56">
            <div style="width:100%;float:left;">
                <label style="font-size:12px;margin-left:10px;">地区名称：</label>
                <input type="text" size="30" class="required" name="region_name" value="{$regioninfo.region_name}"/>
            </div>
            <div style="margin-top: 10px;width:100%;float:left;" id="Rregionbox">
                <label style="font-size:12px;margin-left:10px;">上级地区：</label>
                <select id="Rregion0" s="0" class="Rregion">
                    <option value="0">顶级地区</option>
                    <volist name="clist" id="region">
                        <option value="{$region.region_id}" <?php echo $regioninfo["country_id"] == $region["region_id"] ? "selected='true'" : "";?> >{$region.region_name}</option>
                    </volist>
                </select>

                <?php if(!empty($city_list) || !empty($regioninfo["country_id"])) { ?>
                <select id="Rregion1" s="1" class='regioncitys'>
                    <option value="0">全部地区</option>
                    <volist name="city_list" id="region">
                        <option value="{$region.region_id}" <?php echo $regioninfo["city_id"] == $region["region_id"] ? "selected='true'" : "";?> >{$region.region_name}</option>
                    </volist>
                </select>
                <?php } ?>
            </div>
            <div style="width:100%;float:left;margin-top:10px;">
                <label style="font-size:12px;margin-left:10px;">区号：</label>
                <input type="text" size="30" class="" name="code" value="{$regioninfo.code}"/>
            </div>
        </div>
        
        <div class="formBar">        
        <ul>
            <if condition="in_array('update', $privilegelist)">
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <input type="hidden" name="region_id" value="{$regioninfo.region_id}" />
                        <input type="hidden" id="Rregion" name="parent_id" value="{$regioninfo.parent_id}"/>
                        <button type="submit">保存</button>
                    </div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">取消</button>
                    </div>
                </div>
            </li>
            </if>
        </ul>
        </div>
    </form>
</div>
<script type="text/javascript">
    

    $(".regioncitys").live("change",function(){
        var p_id = $(this).val();
        if(p_id == 0) {
            var pid = $(".Rregion").val();
            $("#Rregion").val(pid);
        } else {
            $("#Rregion").val(p_id);
        }
    });

    $(".Rregion").unbind("change").change(function(){
        var p_id = $(this).val();

        if(p_id == 0) {
            $("#Rregion").val(0);
        } else {
            $("#Rregion").val(p_id);
        }

        $(".regioncitys").remove();

        if(p_id != 0) {
            $.post(
                "__URL__/getRegions",
                {
                    'parent_id': p_id
                },
                function (data) {
                    data = eval("(" + data + ")");
                    if (1 == data.status) {
                        $("#Rregionbox").append(data.data);
                    }
                }
            );
        }

    });
</script>